import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FoodVO, FoodForm, FoodQuery } from '@/api/canteen/food/types';

/**
 * 查询食材管理列表
 * @param query
 * @returns {*}
 */

export const listFood = (query?: FoodQuery): AxiosPromise<FoodVO[]> => {
  return request({
    url: '/canteen/food/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询食材管理详细
 * @param foodId
 */
export const getFood = (foodId: string | number): AxiosPromise<FoodVO> => {
  return request({
    url: '/canteen/food/' + foodId,
    method: 'get'
  });
};

/**
 * 新增食材管理
 * @param data
 */
export const addFood = (data: FoodForm) => {
  return request({
    url: '/canteen/food',
    method: 'post',
    data: data
  });
};

/**
 * 修改食材管理
 * @param data
 */
export const updateFood = (data: FoodForm) => {
  return request({
    url: '/canteen/food',
    method: 'put',
    data: data
  });
};

/**
 * 删除食材管理
 * @param foodId
 */
export const delFood = (foodId: string | number | Array<string | number>) => {
  return request({
    url: '/canteen/food/' + foodId,
    method: 'delete'
  });
};
